package cn.smart.epic.core.intercept;

import cn.smart.epic.common.controller.BaseController;
import cn.smart.epic.core.util.HttpSessionHolder;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Auther Z.B
 * @date 2017/10/11 14:07
 * @Email 2545375@qq.com
 * @Description 静态调用session的拦截器
 * @since 1.0
 */

@Aspect
@Component
public class SessionInterceptor extends BaseController {

    @Pointcut("execution(* cn.smart.epic.*..controller.*.*(..))")
    public void cutService(){

    }

    @Around("cutService()")
    public Object sessionKit(ProceedingJoinPoint point)throws Throwable {
        HttpSessionHolder.put(super.getHttpServletRequest().getSession());
        try{
           return point.proceed();
        }finally {
            HttpSessionHolder.remove();
        }
    }
}
